<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>东东商城，欢迎登录</title>

    <link rel="stylesheet" type="text/css" href="css/webbase.css"/>
    <link rel="stylesheet" type="text/css" href="css/pages-login.css"/>
</head>

<body>
<div class="login-box">
    <!--head-->
    <div class="py-container logoArea">
        <a href="" class="logo-bd"></a>
    </div>
    <!--loginArea-->
    <div class="loginArea">
        <div class="py-container login">
            <div class="loginform">
                <ul class="sui-nav nav-tabs tab-wraped">
                    <li>
                        <a href="#index" data-toggle="tab">
                            <h3>扫描登录</h3>
                        </a>
                    </li>
                    <li class="active">
                        <a href="#profile" data-toggle="tab">
                            <h3>账户登录</h3>
                        </a>
                    </li>
                </ul>
                <div class="tab-content tab-wraped">
                    <div id="index" class="tab-pane">
                        <p>二维码登录，暂为官网二维码</p>
                        <img src="img/wx_cz.jpg"/>
                    </div>
                    <div id="profile" class="tab-pane  active">
                        <form class="sui-form">
                            <div class="input-prepend"><span class="add-on loginname"></span>
                                <input id="username1" type="text" placeholder="邮箱/用户名/手机号" class="span2 input-xfat">
                            </div>
                            <div class="input-prepend"><span class="add-on loginpwd"></span>
                                <input id="password1" type="password" placeholder="请输入密码" class="span2 input-xfat">
                            </div>
                            <div class="setting">
                                <label class="checkbox inline">
                                    <input name="m1" type="checkbox" value="2" checked="">
                                    自动登录
                                </label>
                                <a type="button" href="javascript:forgetPwd()">忘记密码？</a>
                            </div>
                            <div class="logined">
                                <input type="button" class="sui-btn btn-block btn-xlarge btn-danger" value="登录"
                                       onclick="UserLogin()">
                            </div>
                        </form>
                        <div class="otherlogin">
                            <div class="types">
                                <ul>
                                    <li><img src="img/qq.png" width="35px" height="35px"/></li>
                                    <li><img src="img/sina.png"/></li>
                                    <li><img src="img/ali.png"/></li>
                                    <li><img src="img/weixin.png"/></li>
                                </ul>
                            </div>
                            <span class="register"><a href="register.html" target="_blank">立即注册</a></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--foot-->
    <div class="py-container copyright">
        <ul>
            <li>关于我们</li>
            <li>联系我们</li>
            <li>联系客服</li>
            <li>商家入驻</li>
            <li>营销中心</li>
            <li>手机东东商城</li>
            <li>销售联盟</li>
            <li>东东商城社区</li>
        </ul>
        <div class="address">地址：北京市昌平区沙阳路18号 邮编：100000 电话：400-0123-302</div>
        <div class="beian">京ICP备08006666号京公网安备11010888888
        </div>
    </div>
</div>

<script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="js/pages/login.js"></script>

<script src="js/pages/public.js"></script>
</body>
<script th:inline="javascript">
    function UserLogin() {
        $.ajax({
            url: goods + "/userlogin/userlogin",
            // contentType: "application/json;charset=utf-8",//我将来要往前台发送数据的时候是以json的格式发送的
            dataType: "json",
            type: "post",//必须指定请求类型
            data: {
                username: $("#username1").val(),
                password: $("#password1").val()
            },//往后台发送的确确实实是一个json数据  JSON.stringify({})
            success: function (result) {
                if (result.code == 2) {//登录成功
                    console.log(result)

                    //将token保存在浏览器的缓存中
                    window.localStorage.setItem("token", result.data)

                    //登录成功，跳转页面
                    top.window.location.href = "./index.html";
                } else {
                    alert(result.message)
                }
            }, error: function () {
                alert("登录异常，请联系管理员")
            }
        })
    }


    //忘记密码  通过发送邮件方式找回
    function forgetPwd() {
        console.log($("#username1").val())
        $.ajax({
            url: goods + "/user/forgetPwd",
            contentType: "application/json;charset=utf-8",//我将来要往前台发送数据的时候是以json的格式发送的
            dataType: "json",
            type: "get",//必须指定请求类型
            data: {username: $("#username1").val()},//往后台发送的确确实实是一个json数据  JSON.stringify({})
            success: function (result) {
                if (result.code == 11) {//登录成功
                    alert("ok , 去看邮箱")
                } else {
                    alert(result.message)
                }
            }, error: function () {
                alert("找回异常，请联系管理员")
            }
        })
    }
</script>
</html>